#ifndef ENTITY_H
#define ENTITY_H
#include <list>
#include <ClanLib/core.h>
#include <ClanLib/display.h>
#include "level.h"
#include "viewport.h"

class Entity
{
public:
	CL_Pointf pos;
	CL_Pointf oldPos;
	CL_Size size;
	CL_Vector2 vel;
	CL_Vector2 accel;

	CL_Rect dest;
	CL_Sprite *sprite;
	CL_CollisionOutline outline;
	int tile;
	int sprite_frame;
	float rot;
	bool onGround;

	CL_Rectf tileArea;
	float hOffset;
	float vOffset;

private:
	inline void hitRoof();
	inline void hitFloor();
	inline void hitLeftWall();
	inline void hitRightWall();

public:
	// Draw the entity
	void update(Viewport &viewport, Level &level);
	virtual inline void physics(float &time, Level &level);
	virtual inline void logic(float &time);

	// Getter / setter functions
	CL_Pointf getPos();
	float getRot();
	void setPos(CL_Pointf position);
	void setRot(float rotation);

	Entity();
	Entity(CL_Sprite &sprite_copy);
	Entity(CL_Sprite &sprite_copy, CL_Pointf &initial_position);
	~Entity();
};

class EntityManager
{
	std::list<Entity*> entities;

public:
	void draw(Viewport &viewport, Level &level);
	void add();
	void add(Entity &entity);
	void clear();

	EntityManager();
	~EntityManager();
};

#endif